import contextlib
import os


class FileUtil:
    @staticmethod
    def get_dir_url():
        return os.path.abspath(os.getcwd())

    @staticmethod
    def get_file_url(file_name):
        file_url = os.path.abspath(os.path.join(os.getcwd(), file_name))
        if not os.path.exists(file_url):
            open(file_name, 'w')
        return file_url


@contextlib.contextmanager
def atomic_overwrite(filename):
    temp = filename + '~'
    with open(temp, "w") as f:
        yield f
    os.rename(temp, filename) # this will only happen if no exception was raised

if __name__ == '__main__':
    print(FileUtil.get_file_url('deal_record.csv'))
